<?php
$config = new RM_Config();
$currencySymbol = $config->getValue('rm_config_currency_symbol');

$unitConfig = new RM_UnitDailyPricesConfig();
$weekendEnabled = $unitConfig->fetchValueByUnit($this->unit->id, 'weekend_price_enabled');

if ($weekendEnabled) {
    $datesWidth = "10%;";
} else {
    $datesWidth = "17%;";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr" id="minwidth" >
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    </head>
    <body>
        <link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/userdata/modules/ExcursionPrices/css/main.css" />
        <div class="RM_price_module_pricelist_container">
            <div class="RM_price_module_pricelist_header_container">
                <div class="RM_price_module_pricelist_header">
                    <?php echo $this->unit->name."&nbsp;".$this->_translate->_('User.Unit.Prices','Title');?>
                </div>
            </div>
            <div class="RM_divTable">
                <div class="RM_divHeaderRow">
                    <div class="RM_divHead_name">
                        <?php echo $this->_translate->_('User.Unit.List','Period');?>
                    </div>
                    <div class="RM_divHead_startdate" >
                        <?php echo $this->_translate->_('User.Unit.List','StartDate');?>
                    </div>
                    <div class="RM_divHead_enddate">
                        <?php echo $this->_translate->_('User.Unit.List','EndDate');?>
                    </div>
                    <div class="RM_divHead">
                        <?php echo $this->_translate->_('User.Unit.List','AdultWeekdayPrice');?>
                    </div>
                    <?php if ($weekendEnabled) { ?>
                    <div class="RM_divHead">
                            <?php echo $this->_translate->_('User.Unit.List','AdultWeekendPrice');?>
                    </div>
                        <?php } ?>
                    <div class="RM_divHead">
                        <?php echo $this->_translate->_('User.Unit.List','AdultWeeklyPrice');?>
                    </div>
                    <div class="RM_divHead">
                        <?php echo $this->_translate->_('User.Unit.List','ChildWeekdayPrice');?>
                    </div>
                    <?php if ($weekendEnabled) { ?>
                    <div class="RM_divHead">
                            <?php echo $this->_translate->_('User.Unit.List','ChildWeekendPrice');?>
                    </div>
                        <?php } ?>
                    <div class="RM_divHead">
                        <?php echo $this->_translate->_('User.Unit.List','ChildWeeklyPrice');?>
                    </div>
                    <div class="RM_divHead">
                        <?php echo $this->_translate->_('User.Unit.List','InfantWeekdayPrice');?>
                    </div>
                    <?php if ($weekendEnabled) { ?>
                    <div class="RM_divHead">
                            <?php echo $this->_translate->_('User.Unit.List','InfantWeekendPrice');?>
                    </div>
                        <?php } ?>
                    <div class="RM_divHead">
                        <?php echo $this->_translate->_('User.Unit.List','InfantWeeklyPrice');?>
                    </div>
                </div>
                <?php
                $config = new RM_Config();
                $dateFormat = $config->getJSDateformat();
                $prices = $this->prices;
                $i=0;
                foreach ($prices as $price) {
                    if ($i % 2 != 0) {
                        // odd rows
                        $rowStyle = "RM_list_row_style1";
                    } else {
                        // even rows
                        $rowStyle = "RM_list_row_style2";
                    }
                    $i++; # Increment our row counter
                    ?>

                <div class="RM_divRow" class="<?php echo $rowStyle;?>">
                    <div class="RM_divColumn_name">
                        <!-- period_name -->
                            <?php echo $price['period_name'];?>
                    </div>
                    <div class="RM_divColumn_startdate">
                        <!-- start_datetime -->
                            <?php echo date($dateFormat, strtotime($price['start_datetime']));?>
                    </div>
                    <div class="RM_divColumn_enddate">
                        <!-- end_datetime -->
                            <?php echo date($dateFormat, strtotime($price['end_datetime']));?>
                    </div>
                    <div class="RM_divColumn">
                        <!-- weekday_price -->
                            <?php
                            if ($price['adult_weekday_price']>0){
                                echo $currencySymbol.$price['adult_weekday_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>
                        <?php if ($weekendEnabled) { ?>
                    <div class="RM_divColumn">
                        <!-- weekend_price -->
                            <?php
                            if ($price['adult_weekend_price']>0){
                                echo $currencySymbol.$price['adult_weekend_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>
                            <?php } ?>
                    <div class="RM_divColumn">
                        <!-- weekly_rate -->
                            <?php
                            if ($price['adult_weekly_price']>0){
                                echo $currencySymbol.$price['adult_weekly_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>

                    <div class="RM_divColumn">
                        <!-- weekday_price -->
                            <?php
                            if ($price['child_weekday_price']>0){
                                echo $currencySymbol.$price['child_weekday_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>
                        <?php if ($weekendEnabled) { ?>
                    <div class="RM_divColumn">
                        <!-- weekend_price -->
                            <?php
                            if ($price['child_weekend_price']>0){
                                echo $currencySymbol.$price['child_weekend_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>
                            <?php } ?>
                    <div class="RM_divColumn">
                        <!-- weekly_rate -->
                            <?php
                            if ($price['child_weekly_price']>0){
                                echo $currencySymbol.$price['child_weekly_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>

                    <div class="RM_divColumn">
                        <!-- weekday_price -->
                            <?php
                            if ($price['infant_weekday_price']>0){
                                echo $currencySymbol.$price['infant_weekday_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>
                        <?php if ($weekendEnabled) { ?>
                    <div class="RM_divColumn">
                        <!-- weekend_price -->
                            <?php
                            if ($price['infant_weekend_price']>0){
                                echo $currencySymbol.$price['infant_weekend_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>
                            <?php } ?>
                    <div class="RM_divColumn">
                        <!-- weekly_rate -->
                            <?php 
                            if ($price['infant_weekly_price']>0){
                                echo $currencySymbol.$price['infant_weekly_price'];
                            } else {
                                echo $this->_translate->_('User.Unit.List','Free');
                            }
                            ?>
                    </div>
                </div>
                    <?php
                }
                ?>
            </div>
        </div>
    </body>
</html>